<template>
  <a-table :columns="columns" :data-source="records" rowKey="id" bordered>
    <span slot="statusRender" slot-scope="text, record">
      <span v-if="record.isDeliver == 1"> 是 </span>
      <span v-else> 否 </span>
    </span>
    <span slot="taxRateRender" slot-scope="text, record">
      {{ record.taxRate + '%' }}
    </span>
    <span slot="percentageRender" slot-scope="text, record">
      {{ record.percentage + '%' }}
    </span>
  </a-table>
</template>

<script>
import { getAction, postAction } from '@/api/manage'
export default {
  props: {
    contractId: {
      type: Number,
      default: 0,
    },
  },
  data() {
    return {
      columns: [
        {
          title: '层级',
          dataIndex: 'layer',
          key: 'layer',
        },
        {
          title: '款项名称',
          dataIndex: 'moneyName',
          key: 'moneyName',
        },
        {
          title: '付款条件',
          dataIndex: 'paymentConditions',
          key: 'paymentConditions',
        },
        {
          title: '款项金额',
          dataIndex: 'amount',
          key: 'amount',
        },
        {
          title: '税率',
          dataIndex: 'taxRate',
          key: 'taxRate',
          scopedSlots: { customRender: 'taxRateRender' },
        },
        {
          title: '百分比',
          dataIndex: 'percentage',
          key: 'percentage',
          scopedSlots: { customRender: 'percentageRender' },
        },
        {
          title: '费用号',
          dataIndex: 'wbsNumber',
          key: 'wbsNumber',
        },
        {
          title: '关联节点工期',
          dataIndex: 'timeLimitName',
          key: 'timeLimitName',
        },
        {
          title: '过账',
          dataIndex: 'isDeliver',
          key: 'isDeliver',
          scopedSlots: { customRender: 'statusRender' },
        },
      ],
      records: [],
      urls: {
        loadContractInstallments: '/hte/contract/loadContractInstallments',
      },
    }
  },
  mounted() {
    this.fetchList()
  },
  methods: {
    fetchList() {
      if(this.contractId && this.contractId!=null){
        getAction(this.urls.loadContractInstallments + '/' + this.contractId, {}).then((res) => {
          if (res.success) {
            this.records = res.result
          }
        })
      }
    },
  },
  watch: {
    contractId(newV, oldV) {
      debugger
      if (newV > 0) {
        this.fetchList()
      } else {
        this.records = []
      }
    },
  },
}
</script>

<style>
</style>